{% extends 'admin/change_form.html' %}

{% block content %}

{{ block.super }}
<div class="side-preview">
  <h2>Preview</h2>
  <object data="/fetch/preview/{{object_id}}"></object>
</div>

{% if next_object %}
	<script type="text/javascript">//<![CDATA[
		(function($){
			$('<input type="submit" value="Save and edit next" name="_saveandeditnext" />')
			.prependTo('div.submit-row');
			$('<input type="hidden" value="{{next_object}}" name="_next_object" />')
			.prependTo('div.submit-row');
		})(django.jQuery);
	//]]></script>
{% endif %}

{% endblock content %}

{% block extrastyle %}
{{ block.super }}
<style>
.side-preview {
    width: 100%;
    height: 800px;
    clear: both;
}

.side-preview object {
    height: 100%;
    width: 100%;
}

@media screen and (min-width: 1500px) {
    #content-main {
        width: 50%;
    }
    #footer {
        padding: 0;
    }
    .side-preview {
        float: right;
        width: 40%;
        height: 80vh;
        clear: none;
    }
}
</style>
{% endblock %}

{% block footer %}

	{{ block.super }}

	{# Hack to force Django to make the created date a date input rather than `text` (the default) #}
	<script>
		django.jQuery(".field-created input").first().attr("type", "date")
	</script>

{% endblock footer %}
